package com.example.cofeed.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.PhoneUtils;
import com.example.cofeed.R;
import com.example.cofeed.api.ApiService;
import com.example.cofeed.base.BaseActivity;
import com.example.cofeed.callback.DialogCallback;
import com.example.cofeed.callback.LzyResponse;
import com.lzy.okgo.model.Response;
import com.umeng.analytics.MobclickAgent;

import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class RegisterSucessActivity extends BaseActivity {

    @BindView(R.id.tv_num)
    TextView mTvNum;
    @BindView(R.id.layout_login)
    LinearLayout mLayoutLogin;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_register_sucess;
    }

    @Override
    protected void init(Bundle savedInstanceState, View container) {
        setMainTitle("注册成功");


        int read_num = getIntent().getIntExtra("read_num", 0);
        if (read_num > 0){
            mLayoutLogin.setVisibility(View.VISIBLE);
            mTvNum.setText("立即登录试看" + read_num + "条");
            mLayoutLogin.setOnClickListener(v -> {
                finish();
            });

        }else {
            mLayoutLogin.setVisibility(View.GONE);
        }

    }

    @OnClick(R.id.layout_phone)
    public void onViewClicked() {
        ApiService.service_phone(this, new DialogCallback<LzyResponse<Map<String, String>>>(this) {
            @Override
            public void onSuccess(Response<LzyResponse<Map<String, String>>> response) {
                String tel = response.body().data.get("tel");
                PhoneUtils.dial(tel);

            }
        });
    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

}
